package com.yunxin.core.infra.persistence.mapper.order;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.yunxin.core.application.dto.order.ChannelPromotionTwoUvStatisticsVo;
import com.yunxin.core.application.dto.order.PidAndTimeDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * @author zero°
 * @since 2023-07-17
 */
@DS("core")
@Mapper
public interface OrderUserUvExtendMapper extends OrderUserUvMapper {

    /**
     * 根据订单id更新订单提交时间
     * @param id id
     * @param submitTime submitTime
     * @return count
     */
    int updateOrderUserUvSubmitTimeById(@Param("id") Long id,
                                        @Param("submitTime")Date submitTime);

    /**
     * 根据用户和产品查询uv订单id
     * @param userCode userCode
     * @param productId productId
     * @return Long
     */
    Long getOrderUserUvIdByUserAndProduct(@Param("userCode") String userCode,
                                          @Param("productId") Long productId);

    /**
     * 根据userCode查询用户uv订单的产品id
     * @param userCode userCode
     * @return  List<Long>
     */
    List<Long> listUvOrderProductIdByUser(@Param("userCode") String userCode);

    List<PidAndTimeDTO> selectPidAndTimeByUserCode(@Param("userCode") String userCode);

    /**
     * 查询二次uv统计需要的数据
     * @param userCode
     * @param productId
     * @param channelId
     * @return
     */
    ChannelPromotionTwoUvStatisticsVo selectOrderUserDetail(@Param("userCode")String userCode,@Param("productId") Long productId,@Param("channelId") Long channelId);

    /**
     * 保存二次uv统计数据
     * @param dto
     */
    void saveOrderUserTwoUv(ChannelPromotionTwoUvStatisticsVo dto);

}
